package com.tsingtree.modular.controller.view;

import com.tsingtree.base.auth.annotion.Permission;
import com.tsingtree.base.pojo.page.LayuiPageInfo;
import com.tsingtree.modular.entity.NanGame;
import com.tsingtree.modular.model.params.NanGameParam;
import com.tsingtree.modular.service.NanGameService;
import com.tsingtree.roses.core.base.controller.BaseController;
import com.tsingtree.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 游戏控制器
 *
 * @author jagger
 */
@Controller
@RequestMapping("/nanGame")
public class NanGameController extends BaseController {

    private String PREFIX = "/nanGame";

    @Autowired
    private NanGameService nanGameService;

    /**
     * 跳转到主页面
     *
     * @author jagger
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/nanGame.html";
    }

    /**
     * 新增页面
     *
     * @author jagger
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/nanGame_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jagger
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/nanGame_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jagger
     */
    @RequestMapping("/addItem")
    @Permission
    @ResponseBody
    public ResponseData addItem(NanGameParam nanGameParam) {
        this.nanGameService.add(nanGameParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author jagger
     */
    @RequestMapping("/editItem")
    @Permission
    @ResponseBody
    public ResponseData editItem(NanGameParam nanGameParam) {
        this.nanGameService.update(nanGameParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author jagger
     */
    @RequestMapping("/delete")
    @Permission
    @ResponseBody
    public ResponseData delete(NanGameParam nanGameParam) {
        nanGameParam.setIsDel(true);
        this.nanGameService.update(nanGameParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author jagger
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(NanGameParam nanGameParam) {
        NanGame detail = this.nanGameService.getById(nanGameParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jagger
     */
    @ResponseBody
    @Permission
    @RequestMapping("/list")
    public LayuiPageInfo list(NanGameParam nanGameParam) {
        return this.nanGameService.findPageBySpec(nanGameParam);
    }

}


